/**
 * Created by IntelliJ IDEA.
 * User: Egor
 * Date: 13.12.11
 * Time: 20:46
 * To change this template use File | Settings | File Templates.
 */
package org.electronic.registration.model {
import mx.collections.ArrayCollection;

import org.electronic.registration.bo.Doctor;
import org.electronic.registration.event.SchedulerEvent;
import org.electronic.registration.event.Sed;
import org.electronic.registration.service.SchedulerService;

public class SchedulerModel implements ISchedulerModel {

    private var _schedulerService:SchedulerService = new SchedulerService();

    public function SchedulerModel() {
    }

    public function getGeneratedSchedulerForDoctor(doctor:Doctor):void {
        _schedulerService.generateSchedulerForDoctor(doctor, onDoctorSchedulerLoaded)
    }

    private function onDoctorSchedulerLoaded(result:Object):void {
        var schProvider:ArrayCollection = ArrayCollection(result);
        var schedulerEvent:SchedulerEvent = new SchedulerEvent(SchedulerEvent.SCHEDULER_LOADED);
        schedulerEvent.setScheduler(schProvider);
        Sed.dispatch(schedulerEvent);
    }
}
}
